

#ifndef SER_DEP_TRANSPORT_H__
#define SER_DEP_TRANSPORT_H__

#include <stdbool.h>
#include <stdint.h>

typedef enum {
    FRAGMENT_INTERMEDIATE = 0x00,
    FRAGMENT_FINAL = 0x40,
    FRAGMENT_INITIAL = 0x80,
    FRAGMENT_STANDALONE = 0xC0,
    FRAGMENT_EXTENSION = 0xE0
} ser_dep_fragment_type_t;

#define EXT_END_OF_TRANSACTION 0x01
#define EXT_STATUS_SUCCESS 0x01

typedef struct {
    uint8_t header;
    uint8_t *payload;
} ser_dep_frame_payload_t;

typedef struct {
    uint16_t len;
    ser_dep_frame_payload_t payload;
} ser_dep_frame_t;

typedef struct ser_dep_serialized_s {
    ser_dep_frame_t *frame;
    struct ser_dep_serialized_s *next;
} ser_dep_serialized_t;

typedef struct {
    ser_dep_serialized_t *s;

} ser_dep_serializer_ctx_t;
ser_dep_serialized_t *ser_dep_serialize(ser_dep_serializer_ctx_t *ctx, uint8_t *payload,
                                        uint16_t len);
void ser_dep_destroy_serializer_ctx(ser_dep_serializer_ctx_t *ctx);

bool ser_dep_is_first_fragment(uint8_t const fragment_header);

bool ser_dep_is_last_fragment(uint8_t const fragment_header);

uint16_t ser_dep_get_max_payload(void);

#endif /* SER_DEP_TRANSPORT_H__ */
